package com.service;

import com.dao.LeadRepository;
import com.po.Lead;
import com.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;

@Service
public class LeadServiceImpl implements LeadService {

    @Autowired
    private LeadRepository leadRepository;

    @Override
    public Lead saveLead(Lead lead) {
        Lead lead1 = leadRepository.save(lead);
        return lead1;
    }

    @Override
    public int findLeadSize() {
        return leadRepository.findAll().size();
    }

    @Override
    public Lead findById(Long id) {
        return leadRepository.findAllById(id);
    }

    @Override
    public Page<Lead> findAllByT(Pageable pageable) {
        System.out.println("222");
        return leadRepository.findAllByState(pageable);
    }


}
